<template>
<div>
    </br>
    </br>
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
    <el-form-item label="申请人">
        <el-input v-model="formInline.name" placeholder="申请人"></el-input>
    </el-form-item>
    <el-form-item label="邮箱">
        <el-input  v-model="formInline.email":disabled="true" placeholder="邮箱"></el-input>
    </el-form-item>
    <el-form-item label="申请原因">
        <el-input type="textarea" v-model="formInline.content" placeholder="申请原因"></el-input>
    </el-form-item>
    <el-form-item>
        <el-button type="primary" @click="onSubmit">申请</el-button>
    </el-form-item>
    </el-form>
</div>

    
</template>
<script>
import indexApi from '@/api/certification/index.js'

  export default {
    data() {
      return {
        formInline: {
          name: '',
          email:'',
          content: ''
        }
      }
    },

    created() { // 在渲染之前执行
        this.task()
  
    },
    mounted() { // 在渲染之后执行   

       
    },

    methods: {

      onSubmit() {
        indexApi.applyadmin(this.formInline).then(response => {

            this.$alert('你已经进行申请请等待审批', '权限认证', {
            confirmButtonText: '确定',
            callback: action => {
                    this.$router.push(`/login`)
                }
            })
             
        })
      },

      task(){
        indexApi.getemail().then(response => {
          const authority=response.data.authority
          this.formInline.email=response.data.email
          if(authority===1){
             this.$alert('你已经是管理员了', '权限认证', {
                confirmButtonText: '确定',
                callback: action => {
                     this.$router.push(`/login`)
                    }
                })
             }
           })
      }  
    }
}
</script>
